package com.airport.ticket.controller;

import com.airport.ticket.common.DateUtil;
import com.airport.ticket.common.UrlUtil;
import com.airport.ticket.dao.FlightInfoMapper;
import com.airport.ticket.dao.OrderInfoMapper;
import com.airport.ticket.dao.UserInfoMapper;
import com.airport.ticket.entity.FlightInfo;
import com.airport.ticket.entity.OrderInfo;
import com.airport.ticket.entity.UserInfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 统计相关的Controller
 */
@Log4j2
@Controller
@RequestMapping("/admin")
public class StataController {
    @Autowired
    private OrderInfoMapper orderInfoMapper;

    /**
     * 统计各个航班的订单数据
     * @param model 存储结果
     * @param errorMsg  错误信息
     * @return
     */
    @RequestMapping(value = "/stat_list.html")
    public String orderList(Model model, String errorMsg, HttpServletRequest request) {
        log.info("==查询航班订单统计==");
        model.addAttribute("nav", "6");
        model.addAttribute("title", "航班订单统计");
        if (errorMsg != null && !"".equals(errorMsg)) {
            model.addAttribute("errorMsg", errorMsg);
        }
        Map<String,Object> condMap = new HashMap<>();
        List<Map<String,Object>>  resultList = orderInfoMapper.statList(condMap);
        model.addAttribute("resultList", resultList);
        return "admin/stat/stat_list";
    }
}